#!/bin/bash
function spinner() {
  local spin='-\|/'
  local charwidth=1
  local i=0
  tput civis # cursor invisible
  while true; do
    local i=$(((i + $charwidth) % ${#spin}))
    printf "%s" "${spin:$i:$charwidth}"

    echo -en "\033[1D"
    sleep .1
  done
  tput cnorm
  wait
}

spinner
